import type { DataTableColumns, DataTableProps } from 'naive-ui'
import type { VNodeChild } from 'vue'
import type { NvCrudOption } from '@/crud/types'
import type { NvOption, RowData, Size } from '@/types'

export interface NvDataTableProps {
  'data': RowData[]
  'columns': DataTableColumns
  'option': NvCrudOption
  'pagination'?: DataTableProps['pagination']

  'onLoad'?: DataTableProps['onLoad']
  'onScroll'?: DataTableProps['onScroll']
  'onUpdate:filters'?: DataTableProps['onUpdate:filters']
  'onUpdate:page'?: DataTableProps['onUpdate:page']
  'onUpdate:pageSize'?: DataTableProps['onUpdate:pageSize']
  'onUpdate:sorter'?: DataTableProps['onUpdate:sorter']
}

type ViewSlot = (props: { rowData: RowData, rowIndex: number, mode: 'cell', dictData?: NvOption[], loading?: boolean }) => VNodeChild
export interface NvDataTableSlots {
  table_loading?: () => VNodeChild
  table_empty?: () => VNodeChild
  row_actions?: (props: { rowData: RowData, rowIndex: number, size: Size }) => VNodeChild
  row_actions_pre?: (props: { rowData: RowData, rowIndex: number, size: Size }) => VNodeChild
  [key: `${string}_view`]: undefined | ViewSlot
}
